package pack0824;

import java.io.*;

public class DemoB {
    public static void a(){
        InputStream in = null;
       try{
           File file = new File("D://a/a.txt");
           in = new FileInputStream(file);
           byte[] bytes = new byte[6];
           while (true){
               int len = in.read(bytes);
               if(len == -1){
                   break;
               }
               String Str = new String(bytes,0,len);
               System.out.print(Str);
           }

       }catch (FileNotFoundException e){
           System.out.println(e);
       }catch (IOException e){
           System.out.println(e);
       }catch (Exception e){
           System.out.println(e);
       }finally{
           try {
               in.close();
           }catch (Exception e){
               System.out.println(e);
           }
       }
    }

    public static void b() throws Exception{
        StringBuffer str = new StringBuffer("");
        File file = new File("D://a/a.txt");
        InputStream in = new FileInputStream(file);
        byte[] bytes = new byte[6];
        int len;
        do {
            len = in.read(bytes);
            if (len != -1) {
                String s = new String(bytes, 0, len);
                str.append(s);
                }
        }while (len != -1);
        System.out.print(str);
    }

    public static void main(String[] args) throws Exception {
        b();
    }
}
